/**
 * SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
 * SPDX-License-Identifier: Mulan PSL v2
 */
<template>
    <div class="service-manager-wrap">
        <common-title
            :title-name="pageTitle" />
        <formal-release :model-list="modelList" />
    </div>
</template>
<script  lang="ts">

import {Vue, Component } from 'vue-property-decorator';
import formalRelease from './component/formal_release.vue';
import commonTitle from '../component/common_title.vue';
import trainingUrlAdapter from 'src/home/mod_common/training_url_adapter';

// import store from 'src/vuex/store';
// let userID = store.state.userId;
const MODEL_URL = {
    get:trainingUrlAdapter('project')
};
const PAGE_COUNT = 10000;


@Component({
    components:{
        commonTitle,
        formalRelease
    }
})
export default class ServiceManager extends Vue {
    pageTitle = _('服务管理')
    showEmptyService = false;
    modelParams = {
        keyword: '',
        pageSize: PAGE_COUNT,
        pageNum: 0
    }
    modelList = []

    get projectId () {
        return this.$route.query.projectId || '';
    }

    _showService (isShow: boolean) {
        this.showEmptyService = isShow;
    }
    mounted (): void {
        this._getModelList();
    }

    // 刷新grid
    async _getModelList () {
        // @ts-ignore
        this.modelParams.projectId = this.projectId;
        let jsonData = await this.$ajax.get(`${MODEL_URL.get}/${this.projectId}/model`, this.modelParams);
        let {success, msg, data} = jsonData;
        if (!success) {
            this.$showErr(msg || _('加载数据失败'));
            return;
        }
        this.modelList = data.list.map(item => {
            return {
                label:item.name,
                value:item.id,
                modelId:item.id,
                s3Address:item.s3Address,
                predictor:item.predictor
            };
        });
    }
};
</script>
<style lang="less">
    .service-manager-wrap{
        height: calc(100% - 17px);
        width: calc(100% - 40px);
        
        .sfv-tabpanel .sfv-tabpanel_header .sfv-tabpanel_scroll{
            margin-left: 8px;
        }
        .data-source__tab{
            height: calc(100% - 65px);
            border: 1px solid #ddd;
            .sfv-tabpanel_header{
                border-bottom: 1px solid #ddd;
                height: 41px;
            }
        }
        .sfv-tabpanel_wrap{
            height: calc(100% - 41px);
            box-shadow: none;
            .tabpanel-body-item{
                height: 100%;
            }
        }
    }

</style>
